package com.iwdnb.gkgz.common.utils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import cn.hutool.core.date.DateUtil;

public class MergeDateUtils {

    public static List<String> mergeDateList(List<String> matchDateList, List<String> dateList, int dayInterval) {
        List<String> list = new ArrayList<>();
        for (String d : matchDateList) {
            Date date = DateUtil.parseDate(d);
            for (String d2 : dateList) {
                Date date2 = DateUtil.parseDate(d2);
                Long time = Math.abs(date.getTime() - date2.getTime());
                //2个买点间隔N天之内
                if (time < dayInterval * 86400 * 1000) {
                    if (date.before(date2)) {
                        list.add(d);
                    } else {
                        list.add(d2);
                    }
                    break;
                }
            }
        }
        return list;
    }

}
